<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/12/6
  Time: 19:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="java.sql.*" %>
<%request.setCharacterEncoding("utf-8"); %>
<jsp:useBean id="myDbBean" scope="page" class="org.DbBean"></jsp:useBean>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        String username=request.getParameter("username");
        String pwd=request.getParameter("pwd");
        try {
            myDbBean.OpenConnection();
            String sql="select * from hbeu_user where username='"+username+"'";
            ResultSet rs=myDbBean.executeQuery(sql);
            if(!rs.next())
            {
                String sql1="INSERT INTO `hbeu_user(username,password)` VALUES('"+username+"','"+pwd+"')";
                myDbBean.executeQuery(sql1);
            }
            else {
                String sql1="update hbeu_user set password='"+pwd+"' where username='"+username+"'";
                myDbBean.excuteUpdate(sql1);
            }
            rs.close();
            myDbBean.closeConnection();
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    %>
</body>
</html>
